package com.bc.bclocalserviceapihttp.controller;

import com.bc.bcapi.service.T_Mng_quartzserviceService;
import com.bc.bcmodel.domain.T_Mng_quartzserviceModel;
import com.bc.bcmodel.req.QuartzHttpModel;
import com.bc.bcmodel.req.QuartzStartListReq;
import com.bc.commonentity.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Name QuartzConfigController
 * @Description
 * @Author douhaichao
 * @Date 2018/8/17 20:52
 * @Version 1.0
 **/
@Api("服务列表")
@RestController
@RequestMapping("quartzconfig")
public class QuartzConfigController {
    @Autowired
    T_Mng_quartzserviceService t_mng_quartzserviceService;

    @ApiOperation("获取服务列表")
    @RequestMapping(value = "querystartlist", method = {RequestMethod.POST, RequestMethod.GET})
    public JsonResult queryStartList(@RequestBody QuartzStartListReq req) {
        QuartzHttpModel result = t_mng_quartzserviceService.queryStartList(req.getPlatform_id());
        // 如果版本号一致，则说明没有变更，则返回空集合，减少网络传输
        // 此处必须和qutartzservice中的Main.refreshDo保持一致
        if (result != null && result.getVersionCode().equals(req.getVersion_code())) {
            result.setListData(null);
        }
        return new JsonResult(result);
    }
}
